import UIKit

import SnapKit

@objcMembers
public class AMNFilterPlusPopView: CATBaseTipView {
    // 标题
    private lazy var jSteeplechaseLabel: UILabel = {
        let docked = UILabel()
        docked.text = "Filter".localized()
        docked.textColor = UIColor(red: 49.0 / 255.0, green: 48.0 / 255.0, blue: 51.0 / 255.0, alpha: 1.0)
        docked.font = .systemFont(ofSize: 18, weight: .bold)
        return docked
    }()

    // 重置按钮
    private lazy var cNonnullButton: UIButton = {
        let abstract = UIButton(type: .custom)
        abstract.backgroundColor = UIColor(red: 245.0 / 255.0, green: 245.0 / 255.0, blue: 247.0 / 255.0, alpha: 1.0)
        abstract.layer.cornerRadius = 24
        abstract.layer.masksToBounds = true
        abstract.setTitle("Reset".localized(), for: .normal)
        abstract.setTitleColor(UIColor(red: 131.0 / 255.0, green: 130.0 / 255.0, blue: 134.0 / 255.0, alpha: 1.0), for: .normal)
        abstract.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
        abstract.addTarget(self, action: #selector(vhOnResetTap(sender:)), for: .touchUpInside)
        return abstract
    }()

    // 完成按钮
    private lazy var mCompleteButton: UIButton = {
        let ultimate = UIButton(type: .custom)
        ultimate.backgroundColor = UIColor(red: 175.0 / 255.0, green: 81.0 / 255.0, blue: 255.0 / 255.0, alpha: 1.0)
        ultimate.layer.cornerRadius = 24
        ultimate.layer.masksToBounds = true
        ultimate.setTitle("Confirm".localized(), for: .normal)
        ultimate.setTitleColor(.white, for: .normal)
        ultimate.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
        ultimate.addTarget(self, action: #selector(vhonConfirmTap(sender:)), for: .touchUpInside)
        return ultimate
    }()

    // 性别text
    private lazy var qLz4Label: UILabel = {
        let cadence = UILabel()
        cadence.text = "Gender".localized()
        cadence.textColor = UIColor(red: 131.0 / 255.0, green: 130.0 / 255.0, blue: 134.0 / 255.0, alpha: 1.0)
        cadence.font = .systemFont(ofSize: 16, weight: .regular)
        return cadence
    }()

    // 选择男
    private lazy var jTruncatedBtn: UIButton = {
        let horizontal = UIButton(type: .custom)
        horizontal.backgroundColor = UIColor(red: 245.0 / 255.0, green: 245.0 / 255.0, blue: 247.0 / 255.0, alpha: 1.0)
        horizontal.layer.cornerRadius = 8
        horizontal.layer.masksToBounds = true
        horizontal.setTitle("Male".localized(), for: .normal)
        horizontal.setTitleColor(.black, for: .normal)
        horizontal.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
        horizontal.addTarget(self, action: #selector(vhOnMaleTap(sender:)), for: .touchUpInside)
        return horizontal
    }()

    // 选择女
    private lazy var iDuffelButton: UIButton = {
        let cologne = UIButton(type: .custom)
        cologne.backgroundColor = UIColor(red: 175.0 / 255.0, green: 81.0 / 255.0, blue: 255.0 / 255.0, alpha: 1.0)
        cologne.layer.cornerRadius = 8
        cologne.layer.masksToBounds = true
        cologne.setTitle("Female".localized(), for: .normal)
        cologne.setTitleColor(.white, for: .normal)
        cologne.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
        cologne.addTarget(self, action: #selector(vhOnFemaleTap(sender:)), for: .touchUpInside)
        return cologne
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        startJewelryHopscotchViews()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        startJewelryHopscotchViews()
    }

    private func startJewelryHopscotchViews() {
        // UI组件初始化
        /// 标题
        vhbsView.addSubview(jSteeplechaseLabel)
        jSteeplechaseLabel.snp.makeConstraints { make in
            make.top.equalTo(16)
            make.centerX.equalTo(10)
            make.height.equalTo(22)
        }

        /// 重置按钮
        vhbsView.addSubview(cNonnullButton)
        cNonnullButton.snp.makeConstraints { make in
            make.leading.equalTo(20)
            make.bottom.equalTo(-16)
            make.height.equalTo(48)
        }

        /// 完成按钮
        vhbsView.addSubview(mCompleteButton)
        mCompleteButton.snp.makeConstraints { make in
            make.trailing.equalTo(-10)
            make.centerY.equalTo(10)
            make.height.equalTo(48)
        }

        /// 性别text
        vhbsView.addSubview(qLz4Label)
        qLz4Label.snp.makeConstraints { make in
            make.top.equalTo(54)
            make.leading.equalTo(20)
            make.height.equalTo(20)
        }

        /// 选择男
        vhbsView.addSubview(jTruncatedBtn)
        jTruncatedBtn.snp.makeConstraints { make in
            make.top.equalTo(12)
            make.leading.equalTo(20)
            make.height.equalTo(40)
        }

        /// 选择女
        vhbsView.addSubview(iDuffelButton)
        iDuffelButton.snp.makeConstraints { make in
            make.leading.equalTo(12)
            make.centerY.equalTo(10)
            make.height.equalTo(50)
        }
    }

    @objc func vhOnResetTap(sender _: UIButton) {
        // 处理点击事件
    }

    @objc func vhonConfirmTap(sender _: UIButton) {
        // 处理点击事件
    }

    @objc func vhOnMaleTap(sender _: UIButton) {
        // 处理点击事件
    }

    @objc func vhOnFemaleTap(sender _: UIButton) {
        // 处理点击事件
    }

    public class func vhdyView(vhdyV: UIView?) -> AMNFilterPlusPopView! {
        AMNFilterPlusPopView.vhbsRemove(String(describing: AMNFilterPlusPopView.self))
        let vhbsview = AMNFilterPlusPopView(frame: CGRect(x: 0, y: 0, width: VHbsWidth, height: VHbsHeigth))
        if vhdyV != nil {
            vhdyV!.addSubview(vhbsview)
        } else {
            vhbsWindow()?.addSubview(vhbsview)
        }
        return vhbsview
    }
}
